<div class="bg-light lter b-b wrapper-md">
    <h4 class="m-n font-thin">优惠券管理</h4>
</div>
<div class="wrapper-md ng-scope" ng-controller="couponsCtrl">
    <div class="panel">
        <div class="row wrapper">
            <div class="col-sm-9">
                <form class="form-inline">
                    <div class="form-group">
                        <label class="control-label">名称</label>
                        <input type="text" class="input-sm form-control" ng-model="couponsVO.name">
                    </div>
                    <div class="form-group">
                        <label class="control-label">状态</label>
                        <select class="input-sm form-control" ng-model="couponsVO.status">
                            <option value="">全部</option>
                            <option value="0">已失效</option>
                            <option value="1">使用中</option>
                        </select>
                    </div>
                    <button class="btn btn-sm btn-default" ng-click="findAll()">查询</button>
                </form>
            </div>
            <div class="col-sm-3">
                <div class="pull-right">
                    <a class="btn btn-sm btn-info" ui-sref="app.couponsDetailAdd" target="_blank">添加优惠券</a>
                </div>
            </div>
            <div class="clearfix"></div>
        </div>
        <div class="table-responsive">
            <table class="table table-striped b-t b-light">
                <thead>
                    <tr>
                        <th>优惠券名称</th>
                        <th>价值</th>
                        <th>有效期</th>
                        <th>发放条件</th>
                        <th>状态</th>
                        <th class="text-center">操作</th>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="item in list">
                        <td>{{item.name}}</td>
                        <td>
                            <!--固定金额-->
                            <div ng-if="item.type==0">
                                <div ng-if="item.isOpenRandom==0">
                                    <div>
                                        <p>固定面值: ¥ {{item.price|number:2}}</p>
                                        <p class="h6" ng-if="item.threshold==1">最低消费:¥ {{item.fullPriceReduction}}</p>
                                    </div>
                                </div>
                                <div ng-if="item.isOpenRandom==1">
                                    <div>
                                        <p>随机面值: ¥ {{item.startPrice}} ~ {{item.endPrice}}</p>
                                        <p class="h6" ng-if="item.threshold==1">最低消费: ¥ {{item.fullPriceReduction}}</p>
                                    </div>
                                </div>
                            </div>
                            <!--折扣率-->
                            <div ng-if="item.type==1">
                                <p class="h5">折扣: {{item.discount}}折</p>
                            </div>
                        </td>
                        <td>
                            <div ng-if="item.validTimeState==0">
                                <p class="h6 inline">{{item.validStartTime}}</p>
                                <p class="h6 inline m-r-xs m-l-xs">至</p>
                                <p class="h6 inline">{{item.validEndTime}}</p>
                            </div>
                            <div ng-if="item.validTimeState==1">
                                <p class="h6">领到券当日开始 {{item.validDays}} 天内有效</p>
                            </div>
                        </td>
                        <td>
                            <span class="h6" ng-if="item.grantType==0">无条件发放</span>
                            <span class="h6" ng-if="item.grantType==1">消费满{{item.consumePrice}}赠送</span>
                            <span class="h6" ng-if="item.grantType==2">活动领取发放</span>
                            <span class="h6" ng-if="item.grantType==3">新用户注册赠送</span>
                        </td>
                        <td>
                            <p class="label label-default" ng-if="item.status==0">已失效</p>
                            <p class="label label-success" ng-if="item.status==1">使用中</p>
                        </td>
                        <td class="t-btns text-center">
                            <div ng-if="item.status==1">
                                <button class="btn btn-sm btn-info" ui-sref="app.couponsDetailEdit({id:item.id})">修改</button>
                                <!--<button class="btn btn-sm btn-success"ng-click="createQrcode(item.id,item.name)">领取二维码</button>-->
                                <button class="btn btn-sm btn-danger" ng-click="updateCouponsStatus(item.id)">使失效</button>
                            </div>
                            <div ng-if="item.status==0"  class="text-center">
                                <button class="btn btn-sm btn-danger" ng-click="delCoupons(item.id)">删除</button>
                            </div>
                        </td>
                    </tr>
                </tbody>
            </table>
            <div ng-if="list.length<=0 && !app.loading" class="padder-v text-center">
                <span class="h6">~未搜索到任何数据~</span>
            </div>
            <div>
                <circle-loading ng-if="app.loading"></circle-loading>
            </div>
        </div>
        <footer class="panel-footer">
            <div class="row">
                <div class="col-sm-offset-4 col-sm-4 text-center">
                    <small class="text-muted inline m-t-sm m-b-sm">显示第 {{startRow}} 至 {{endRow}} 项结果，共 {{totalItems}} 项</small>
                </div>
                <div class="col-sm-4 text-right text-center-xs">
                    <pagination boundary-links="true" total-items="totalItems" ng-model="currentPage"
                                ng-change="pageChanged()" max-size="{{maxPageRow}}" class="pagination-sm m-t-none m-b"
                                previous-text="上一页" next-text="下一页"
                                first-text="首页" last-text="尾页"></pagination>
                </div>
            </div>
        </footer>
    </div>
</div>


